###### 20 december 2013 kurgan sity russia Coloveov di ###########
######
scl = 7
######
f_o = open("soch1","r")
print "%!PS-Adobe-3.0 EPSF-3.0"
def readl():
	global r_l
	r_l = f_o.readline()
def text():
	global r_l
	print "/Times-Roman findfont"
	print str(size) +" scalefont"
	print "setfont"
	print "newpath"
	print str(x)+ " " + str(y) + " " + " moveto"
	print "( "+r_l+ " ) show"
readl()
size = scl*1.5
x = 18*scl
y = 81*scl
text()
readl()
size = scl*1.2
x = 40*scl
y = 80*scl
text()
readl()
def massr():
	global mass
	mass = r_l.split()
i = 0
pos_x = scl*3
pos_y = 75 * scl
shag = scl * 2
def noten():
	global Gd,Ad,Bd,C,D,E,F,G,A,B,c,d,e,f,g,a,b
	Gd = pos_y - scl*1.5
	Ad = pos_y - scl*1
	Bd = pos_y - scl*0.5
	C = pos_y + scl*0
	D = pos_y + scl*0.5
	E = pos_y + scl*1
	F = pos_y + scl*1.5
	G = pos_y + scl*2
	A = pos_y + scl*2.5
	B = pos_y + scl*3
	c = pos_y + scl*3.5
	d = pos_y + scl*4
	e = pos_y + scl*4.5
	f = pos_y + scl*5
	g = pos_y + scl*5.5
	a = pos_y + scl*6
	b = pos_y + scl*6.5
noten()
cup = 750 + 10
fill = True
diez = False
dpal = False
dobup = True
vniz = False
trez = False
toch = False
bar = False
bemol = False
becar = False
fill = True
plusp = 0
def nota():
		global pos_x,notta,dob,fill,diez,dpal,dobup,cup,bemol,becar,toch,alter,plusp
		if fill == True:
			print "newpath"
        		print str(pos_x) + " " + str(notta) + " " + str(scl/2)+" 0 360 arc closepath"
        		print "0 0 0 setgray fill"
        		print "stroke"
			if toch == True:
				print "newpath"
        			print str(pos_x+shag/2) + " " + str(notta) + " " + "1.3 0 360 arc closepath"
				print "0 0 0 setgray fill"
				print "0.5 setlinewidth"
        			print "stroke"
		else:
			print "newpath"
        		print str(pos_x) + " " + str(notta) + " " + str(scl/2)+" 0 360 arc closepath"
			print "0.5 setlinewidth"
        		print "stroke"
			if toch == True:
				print "newpath"
        			print str(pos_x+shag/2) + " " + str(notta) + " " + "1.3 0 360 arc closepath"
				print "0 0 0 setgray fill"
				print "0.5 setlinewidth"
        			print "stroke"
			else:
				pass
		if dobd == True:
			print "newpath"
			print str(pos_x-scl)+" "+ str(Ad) +" moveto"
			print str(pos_x+scl)+" "+ str(Ad) +" lineto"
			print str(pos_x-scl)+" "+ str(C) + " moveto"
			print str(pos_x+scl)+" "+ str(C) + " lineto"
			print "0.5 setlinewidth"
			print "stroke"
		else:
			pass
		if dobup == True:
				print "newpath"
				print str(pos_x-10)+" "+ str(a) +" moveto"
				print str(pos_x+10)+" "+ str(a) +" lineto"
				print str(pos_x-10)+" "+ str(cup) + " moveto"
				print str(pos_x+10)+" "+ str(cup) + " lineto"
				print "0.5 setlinewidth"
				print "stroke"
		else:
			pass
		if dpal == True:
			print "newpath"
			print str(pos_x-scl/2)+" "+ str(notta)+ " moveto"
			print str(pos_x-scl/2)+" "+ str(notta-scl*4-plusp)+" lineto"
			print "0.8 setlinewidth"
			print "stroke"		
		else:
			print "newpath"
			print str(pos_x+scl/2)+" "+ str(notta)+ " moveto"
			print str(pos_x+scl/2)+" "+ str(notta+scl*4+plusp)+" lineto"
			print "0.8 setlinewidth"
			print "stroke"
		toch = False
		pos_x = pos_x + shag
		fill = True
		if plusp > 0:
			plusp = plusp - scl/1.5
		else:
			pass
		plusp = 0
def alter():
			global alt
			print "/Times-Roman findfont"
			print "13 scalefont"
			print "setfont"
			print "newpath"
			if trez == True:
				print str(pos_x-scl*3.9) +" " + str(notta+scl/2) + " " + " moveto"
				print "( "+ alt + " ) show"			
			else:
				print str(pos_x-scl*4) +" " + str(notta-scl/1.5) + " " + " moveto"
				print "( "+ alt + " ) show"
def per():
	if dpal == False:
			print "newpath"
			print str(one-shag+scl/2)+" "+ str(onen+scl*4)+ " moveto"
			print str(two-shag+scl/2)+" "+ str(twon+scl*4)+" lineto"
			print "3 setlinewidth"
			print "stroke"
	else:
			print "newpath"
			print str(one-shag-scl/2)+" "+ str(onen-scl*4)+ " moveto"
			print str(two-shag-scl/2)+" "+ str(twon-scl*4)+" lineto"
			print "3 setlinewidth"
			print "stroke"
def takt():
			global pos_x
			print "newpath"
			print str(pos_x+scl/2)+" "+ str(f)+ " moveto"
			print str(pos_x+scl/2)+" "+ str(f-scl*4)+" lineto"
			print "1.3 setlinewidth"
			print "stroke"
			pos_x = pos_x + shag*1.7
def bar():
			global pos_x
			print "newpath"
			print str(pos_x+scl/2)+" "+ str(f)+ " moveto"
			print str(pos_x+scl/2)+" "+ str(f-scl*4)+" lineto"
			print "1 setlinewidth"
			print "stroke"
			print "newpath"
			print str(pos_x+scl)+" "+ str(f)+ " moveto"
			print str(pos_x+scl)+" "+ str(f-scl*4)+" lineto"
			print "4 setlinewidth"
			print "stroke"
def pouse():
			print "/Times-Roman findfont"
			print "15 scalefont"
			print "setfont"
			print "newpath"
			print str(pos_x-15) +" " + str(G) + " " + " moveto"
			print "(R) show"
def liga():
			print "/Times-Roman findfont"
			print "15 scalefont"
			print "setfont"
			print "newpath"
			print str(pos_x-scl*1.5) +" " + str(notta-scl*1.3) + " " + " moveto"
			print "(~) show"
def singl():
		if dpal == True:
			print "newpath"
			print str(pos_x-shag/1.1)+" "+ str(notta-scl*2)+ " moveto"
			print str(pos_x-shag*1.2)+" "+ str(notta-scl*4)+" lineto"
			print "1 setlinewidth"
			print "stroke"
		else:	
			print "newpath"
			print str(pos_x-shag/1.3)+" "+ str(notta+scl*4)+ " moveto"
			print str(pos_x-shag/1.8)+" "+ str(notta+scl*1.2)+" lineto"
			print "1 setlinewidth"
			print "stroke"
		dpal == False
def obrab():
	global pos_x,notta,dobd,fill,i,one,onen,per,two,twon,dpal,dobup,plusp,vniz,trez,toch,bar,alt
	i = 0
	for soch in mass:
		if soch == "||":
			bar()
		elif soch == "|":
			takt()
		for n in soch:
			if n[i] == "B":
				if vniz == True:
					notta = Bd
					pal = True
					dobd = True
					dobup = False
					if trez == True:
						pos_x = pos_x - shag
						nota()
					else:
						nota()
					
				else:
					notta = B
					pal = True
					dobd = False
					dobup = False
					if trez == True:
						pos_x = pos_x - shag
						nota()
					else:
						nota()
			elif n[i] == "C":
					notta = C
					pal = True
					dobd = True
					dobup = False
					if trez == True:
						pos_x = pos_x - shag
						nota()
					else:
						nota()
			elif n[i] == "D":
					notta = D
					pal = True
					dobd = False
					dobup = False
					if trez == True:
						pos_x = pos_x - shag
						nota()
					else:
						nota()	
			elif n[i] == "E":
					notta = E
					dobd = False
					dobup = False
					pal = True
					if trez == True:
						pos_x = pos_x - shag
						nota()
					else:
						nota()	
			elif n[i] == "F":	
					notta = F
					dobd = False
					dobup = False
					pal = True
					if trez == True:
						pos_x = pos_x - shag
						nota()
					else:
						nota()
			elif n[i] == "G":
				if vniz == True:
					notta = Gd
					pal = True
					dobd = True
					dobup = False
					if trez == True:
						pos_x = pos_x - shag
						nota()
					else:
						nota()
				else:
					notta = G
					dobd = False
					dobup = False
					if trez == True:
						pos_x = pos_x - shag
						nota()
					else:
						nota()
			if n[i] == "A":
				if vniz == True:
					notta = Ad
					dpal = False
					dobd = True
					dobup = False
					if trez == True:
						pos_x = pos_x - shag
						nota()
					else:
						nota()
				else:
					notta = A
					dobd = False
					dobup = False
					if trez == True:
						pos_x = pos_x - shag
						nota()
					else:
						nota()
			elif n[i] == "d":
					notta = d
					dobd = False
					dobup = False
					pal = True
					if trez == True:
						pos_x = pos_x - shag
						nota()
					else:
						nota()
			elif n[i] == "e":
					if trez == True:
						notta = e
						dobd = False
						dobup = False
						pal = True
						pos_x = pos_x - shag
						nota()
					else:
						notta = e
						dob = False
						pal = True
						nota()
			elif n[i] == "f":
					if trez == True:
						notta = f
						dobd = False
						dobup = False
						pal = True
						pos_x = pos_x - shag
						nota()
					else:
						notta = f
						dobd = False
						dobup = False
						pal = True
						nota()
			elif n[i] == "g":
					if trez == True:
						notta = g
						dobd = False
						dobup = False
						pal = True
						pos_x = pos_x - shag
						nota()
					else:
						notta = g
						dobd = False
						dobup = False
						pal = True
						nota()
			elif n[i] == "a":
					if trez == True:
						notta = a
						pal = True
						dpal = True
						dopup = True
						dopd = False
						pos_x = pos_x - shag
						nota()
					else:
						notta = a
						pal = True
						dpal = True
						dobup = True
						dopd = False
						nota()
			elif n[i] == "[":
					trez = True
			elif n[i] == "c":
					if trez == True:
						notta = c
						dobd = False
						dobup = False
						pos_x = pos_x - shag
						nota()
					else:
						notta = c
						dobd = False
						dobup = False
						nota()
			elif n[i] == "]":
					trez = False
			elif n[i] == "4":
					fill = False
			elif n[i] == "6":
					fill = False
					toch = True
			elif n[i] == "3":
					fill = True
					toch = True
			elif n[i] == "2":
					fill = True
			elif n[i] == "1":
					singl()
			elif n[i] == "^":
					alt = "#"
					alter()
			elif n[i] == "_":
					alt = "b"
					alter()
			elif n[i] == "=":
					alt = "="
					alter()
			elif n[i] == "(":
					one = pos_x
					onen = notta
			elif n[i] == ")":
					two = pos_x
					twon = notta
					per()
			elif n[i] == "~":
					liga()
			elif n[i] == "u":
				dpal = False
			elif n[i] == "w":
				dpal = True
			elif n[i] == ",":
				vniz = True
				dopd = True
			elif n[i] == "'":
				vniz = False
				dopup = True
			elif n[i] == "+":
				plusp = plusp + scl/1.5
			elif n[i] == "-":
				plusp = plusp - scl/1.5
			elif n[i] == "r":
				pouse()
				pos_x = pos_x + shag/3
			elif n[i] == "p":
				pos_x = pos_x + shag
			else:
				pass
	i = i + 1
def stan():
	global pos_y
	i = 0
	while i < 5:
		print "newpath"
		print "10 "+str(pos_y)+" moveto"
		print "720 "+str(pos_y)+" lineto"
		print "0.5 setlinewidth"
		print "stroke"
		pos_y = pos_y - scl
		i = i + 1
def obs():
	if len(r_l) > 0:
		stan()
		noten()
		obrab()
	else:
		pass
massr()
obs()
readl()
massr()
pos_y = 65 * scl
pos_x = scl*3
obs()
readl()
massr()
pos_y = 55 * scl
pos_x = scl*3
obs()
readl()
massr()
pos_x = scl*3
pos_y = 45 * scl
obs()
f_o.close()
print "% ###################### OK #########################"
